package com.wpfap.kfzapp;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.os.Environment;
import android.widget.ImageView;
import android.widget.TextView;

public class EigenschaftActivity<T> extends Activity {
    private ImageView gfxButton;
	/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.eigenschaft);
        System.out.println(getIntent().getIntExtra("Datei", -1));
        System.out.println(getIntent().getStringExtra("Liste"));
        ImageView im = (ImageView) findViewById(R.id.imageView1);
        File imgFile = new  File(Environment.getExternalStorageDirectory()+"/wpfap/"+getIntent().getStringExtra("Liste")+".jpg");
        Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
        im.setImageBitmap(myBitmap);
        
        File file = new File(Environment.getExternalStorageDirectory()+"/wpfap/"+getIntent().getStringExtra("Liste"));
			System.out.println(file.toString());
        FileReader fr;
		try {
			fr = new FileReader(file);
			BufferedReader out = new BufferedReader(fr);
			String literpreis=out.readLine();
			System.out.println("Info: "+literpreis);
			String gesamtkilometer=out.readLine();
			String liter=out.readLine();
			String euro=out.readLine();
			String tankstelle=out.readLine();
			String kraftstoff=out.readLine();
			TextView tw1 = (TextView) (findViewById(R.id.textView2));
			TextView tw2 = (TextView) (findViewById(R.id.textView3));
			TextView tw3 = (TextView) (findViewById(R.id.textView4));
			TextView tw4 = (TextView) (findViewById(R.id.textView5));
			TextView tw5 = (TextView) (findViewById(R.id.textView6));
			TextView tw6 = (TextView) (findViewById(R.id.textView7));
			tw1.setText("Preis: "+literpreis);
			tw2.setText("Kilometer: "+gesamtkilometer);
			tw3.setText("Liter: "+liter);
			tw4.setText(euro+" EUR");
			tw5.setText("Bei: "+tankstelle);
			tw6.setText(kraftstoff);
			
  			out.close();
  			fr.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    }
}